home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Biz / swood / FW_Scripts.lha / FW_Scripts / ComplexShape / ComplexShape.rexx < prev    next >
OS/2 REXX Batch file  |  2004-08-17  |  2KB  |  89 lines

  1. /* ================================    */
  2. /*  FINAL WRITER AREXX MACRO        */
  3. /*  Create complex shapes from lines    */
  4. /* $VER: ComplexShape 1.0 (2.7.04)    */
  5. /* ================================    */
  6. Options Results
  7.  
  8. SetMeasure MICROPOINTS
  9.  
  10. /* Get a list of all the selected objects. */
  11. i = 0
  12. FirstObject SELECTED
  13. IF ( Result = 0 ) THEN DO
  14.     ShowMessage 1 0 '"No lines selected." "" "" "OK" "" ""'
  15.     EXIT
  16.     END
  17.  
  18. DO WHILE ( Result ~= 0 )
  19.     i = I + 1
  20.     Object.i = Result
  21.     NextObject Object.i SELECTED
  22.     END
  23.  
  24. x = 0
  25. DO WHILE ( x < i )
  26.     x = x + 1
  27.  
  28.     GetObjectType Object.x
  29.     objtype.x = Result
  30.  
  31.     IF (objtype.x ~= 2 & objtype.x ~= 3) THEN DO
  32.         ShowMessage 1 0 '"Wrong object type selected." "" "" "OK" "" ""'
  33.         EXIT
  34.         END
  35.  
  36.     /* Get the coordinates */
  37.     GetObjectCoords Object.x
  38.     PARSE VAR Result page.x x1.x y1.x x2.x y2.x
  39.  
  40.     END
  41.  
  42. closepath = 0
  43. x = 0
  44. DO WHILE ( x < i )
  45.     x = x + 1
  46.  
  47.     IF x = 1 THEN DO
  48.         StartPath page.x x1.x y1.x
  49.         oldx = x1.x
  50.         oldy = y1.x
  51.         startx = x1.x
  52.         starty = y1.x
  53.         END
  54.  
  55.     /* Make a closed path if ends are within 50 micropoints */
  56.     IF (x = i) & (ABS(startx - x2.x) < 50) & (ABS(starty - y2.x) < 50) THEN DO
  57.         x2.x = startx
  58.         y2.x = starty
  59.         closepath = 1
  60.         END
  61.  
  62.     IF objtype.x = 2 THEN DO
  63.         LineTo page.x x2.x y2.x
  64.         END
  65.     ELSE DO
  66.         midx = (oldx + x2.x) / 2
  67.         midy = (oldy + y2.x) / 2
  68.         cp1x = (oldx + midx) % 2
  69.         cp1y = (oldy + midy) % 2
  70.         cp2x = (midx + x2.x) % 2
  71.         cp2y = (midy + y2.x) % 2
  72.         CurveTo page.x cp1x cp1y cp2x cp2y x2.x y2.x
  73.         END
  74.  
  75.     IF x = i THEN DO
  76.         IF closepath THEN
  77.             EndPath CLOSE
  78.         ELSE 
  79.             EndPath
  80.         Redraw
  81.         SetMeasure RULER
  82.         EXIT
  83.         END
  84.  
  85.     oldx = x2.x
  86.     oldy = y2.x
  87.  
  88.     END
  89.